import java.util.Scanner;

public class Main {
        public int reverse(int x) {
            int a = 0;
            while (x != 0) {
                int pop = x % 10;
                if (a > Integer.MAX_VALUE / 10 || (a == Integer.MAX_VALUE / 10 && pop > 7))
                    return 0;
                if (a < Integer.MIN_VALUE / 10 || (a == Integer.MIN_VALUE / 10 && pop < -8))
                    return 0;
                a = a * 10 + pop;
                x /= 10;
            }
            return a;
        }
}
